//
//  BKScoreCollectionViewCell.m
//  TuDianEducation
//
//  Created by lixinkeji on 2021/1/7.
//  Copyright © 2021 zhangbenchao. All rights reserved.
//


#import "BKScoreCollectionViewCell.h"
@interface BKScoreCollectionViewCell()
@property (nonatomic,strong) UIImageView *headImgView;
@property (nonatomic,strong) UILabel *nameLabel;
@property (nonatomic,strong) UILabel *priceLabel;
@property (nonatomic,strong) UILabel *xxPriceLabel;


@end

@implementation BKScoreCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.contentView.backgroundColor = kWhiteColor;
        [self.contentView addSubview:self.headImgView];
        [self.contentView addSubview:self.nameLabel];
        [self.contentView addSubview:self.priceLabel];
        [self.contentView addSubview:self.xxPriceLabel];
    }
    return self;
}
-(UIImageView *)headImgView{
    if (!_headImgView) {
        _headImgView = [[UIImageView alloc]initWithFrame:CGRectMake(TSScaleW(0), TSScaleW(0), self.width, TSScaleW(107))];
        _headImgView.backgroundColor = kSubBacColor;
        
    }
    return _headImgView;
}

-(UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [TSWLTools allocLabel:@"初中数学运算能手" font:systemFont(TSScaleW(14)) textColor:kMainTxtColor frame:CGRectMake(TSScaleW(12), TSScaleW(19) + _headImgView.bottom, self.width - TSScaleW(28), TSScaleW(13)) textAlignment:(NSTextAlignmentLeft)];
        //_nameLabel.numberOfLines = 2;
    }
    return _nameLabel;
}
-(UILabel *)priceLabel{
    if (!_priceLabel) {
        _priceLabel = [TSWLTools allocLabel:@"10000积分" font:systemFont(TSScaleW(12)) textColor:kRedColor frame:CGRectMake(_nameLabel.left, TSScaleW(15) + _nameLabel.bottom, _nameLabel.width, TSScaleW(12)) textAlignment:(NSTextAlignmentLeft)];
    }
    return _priceLabel;
}

-(UILabel *)xxPriceLabel{
    if (!_xxPriceLabel) {
        _xxPriceLabel = [TSWLTools allocLabel:@"￥93" font:systemFont(TSScaleW(12)) textColor:kGrayTxtColor frame:CGRectMake(_nameLabel.left, _priceLabel.top , _nameLabel.width, TSScaleW(12)) textAlignment:(NSTextAlignmentRight)];
        NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
        NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:_xxPriceLabel.text attributes:attribtDic];
        _xxPriceLabel.attributedText = attribtStr;
    }
    return _xxPriceLabel;
}
-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    [_headImgView sd_setImageWithURL:[NSURL URLWithString:_dataDic[@"image"]]];
    
    _nameLabel.text = _dataDic[@"name"];
    NSString *price1 = @"";
    NSString *price2 = @"";
    _xxPriceLabel.hidden = NO;
    if ([kIsmember intValue] == 1) {
        price1 = _dataDic[@"oldprice"];
        price2 = _dataDic[@"newprice"];
    }else{
        _xxPriceLabel.hidden = YES;
        price1 = _dataDic[@"newprice"];
        price2 = _dataDic[@"oldprice"];
    }
    
    _xxPriceLabel.text = [NSString stringWithFormat:@"%@积分",price1];
    NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:_xxPriceLabel.text attributes:attribtDic];
    _xxPriceLabel.attributedText = attribtStr;
    
    _priceLabel.text = [NSString stringWithFormat:@"%@积分",price2];
    
    
}

@end
